/**
 * Created by dell on 2017/3/31.
 */
var ip = "https://apptest.mingpinjiancai.com/";
var guanwangID="https://web.mingpinjiancai.com/";
var old_time=new Date("2014-11-19").getTime();
function get_cookie(name) {
    var cookie_arr = document.cookie.split(";");
    for (var i = 0; i < cookie_arr.length; i++) {
        var small_arr = cookie_arr[i].split("=");
        if (small_arr && $.trim(small_arr[0]) === name) {
            return small_arr[1];
        }
    }
    return false;
}

function set_cookie(name, val, days) {
    var now = new Date().getTime();
    document.cookie = name + "=" + val + ";" + "expires=" + new Date((now + (1000 * 24 * 3600 * days))).toGMTString()+";path=/";
}

function getarr(arr) {
    return JSON.parse(arr);
}

function setarr(arr) {
    localStorage.setItem("arr_danwei", JSON.stringify(arr));
}

function setchicun_arr(arr) {
    localStorage.setItem("arr_chicun", JSON.stringify(arr));
}

function IsPC() {
    var userAgentInfo = navigator.userAgent;
    var Agents = ["Android", "iPhone",
        "SymbianOS", "Windows Phone",
        "iPad", "iPod"];
    var flag = true;
    for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
            flag = false;
            break;
        }
    }
    return flag;
}
//手机号验证
function checkPhone(n){
    var phone =$.trim(n);
    if(!(/^(\d{3,4}-)?\d{7,8}$|^1[34589]\d{9}$/.test(phone))){
        return false;
    }else{
        return true;
    }
}
var key_address = "../mingcai_admin/index.html";
// 时间格式化工具
Date.prototype.format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1,                 //月份
        "d+": this.getDate(),                    //日
        "h+": this.getHours(),                   //小时
        "m+": this.getMinutes(),                 //分
        "s+": this.getSeconds(),                 //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        }
    }
    return fmt;
};
//小数运算防精确度
Math.float_=function (_number,n) {
   if(!isNaN(_number)){
       if(!n){
           return _number;
       }
       var number1= Number((Math.round((Math.round(_number*Math.pow(10,n+5))/Math.pow(10,n+5))*Math.pow(10,n))/Math.pow(10,n)));
     return number1.toFixed(n);
   }else{
       return false;
   }

};
function JsonP(obj) {
    var res=false;
    $.ajax({
        async:false,
        url : obj.url,
        data:obj.data,
        dataType : "jsonp",//数据类型为jsonp
        jsonp: "callback",//服务端用于接收callback调用的function名的参数
        success : function(data){
            obj.success(data);
            res=true;
        },
        error:function(){
            alert('fail');
        }
    });
    setTimeout(function () {
        if(!res){
            if(obj.error){
                obj.error();
            }
        }
    },1000);
}




